<?php
/*
 * based on: http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1
 */

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

// Require the base controller
/*
 * JPATH_CONTROLLER = base component path, also JPATH_COMPONENT_SITE and JPATH_COMPONENT_ADMINISTRATOR are defined
 * DS = directory separator
 */

// Require specific controller if requested (in case multiple controllers are defined)
if($controller = JRequest::getVar('controller')) { //JRequest:getWord() finds a word variable in the URL or the POST data.
    $path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php';
    if (file_exists($path)) {
        require_once $path;
    } else {
        $controller = 'base';  //default controller
        require_once JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php';
    }
}

// Create the controller
$classname    = 'Controller_'.$controller;
$controller   = new $classname( );


if($task = JRequest::getVar('task')) {
}else {
//set default task
    $task = 'display';
}
// Perform the Request task
//$controller->execute('display');
$controller->execute($task);

// Redirect if set by the controller
$controller->redirect();


//don't use a closing php tag in php-only files (common practice to avoid wite-spaces in the output code